package com.app.twth.ui.adjust;


import com.app.twth.app.Constant;
import com.app.twth.base.BaseModel;
import com.app.twth.bean.BaseResponseEntity;
import com.app.twth.net.JsonCallBack;
import com.app.twth.ui.adjust.lpn.AdjustLpnQr;
import com.app.twth.ui.adjust.remeasure.ReMeasureQr;
import com.app.twth.utils.GsonUtil;
import com.lzy.okgo.OkGo;

import java.util.HashMap;
import java.util.Map;

public class AdjustDataModel extends BaseModel {
    public <T> void tallyReTally(String lpn, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>get(Constant.tallyReTally + "/" + lpn)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void tallyReMeasure(ReMeasureQr reMeasureQr, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>post(Constant.tallyReMeasure)
                .tag(this)
                .upJson(GsonUtil.toJson(reMeasureQr))
                .execute(jsonCallBack);
    }

    public <T> void adjustLpn(String ibLpn, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>get(Constant.adjust + "/" + ibLpn)
                .tag(this)
                .execute(jsonCallBack);
    }

    public <T> void adjustInfo(String ibLpn, String barcode, JsonCallBack jsonCallBack) {
        Map<String, String> map = new HashMap<>();
        map.put("ibLpn", ibLpn);
        map.put("barcode", barcode);
        OkGo.<BaseResponseEntity<T>>get(Constant.adjustInfo)
                .tag(this)
                .params(map)
                .execute(jsonCallBack);
    }

    public <T> void adjustInfo(AdjustLpnQr adjustLpnQr, JsonCallBack jsonCallBack) {
        OkGo.<BaseResponseEntity<T>>post(Constant.adjustSubmit)
                .tag(this)
                .upJson(GsonUtil.toJson(adjustLpnQr))
                .execute(jsonCallBack);
    }

}